using System;
using Glue;
using Glue.Internals.Verification;
using Xunit;

namespace GlueTests.MapperVerificationTests
{
    public class When_randomizer_dont_produce_random_values
    {
        public class DomainPerson { public String FirstName { get; set; } }
        public class GuiPerson { public String FirstName { get; set; } }

        private readonly Mapping<DomainPerson, GuiPerson> mapping;
        private readonly MapperVerification<DomainPerson, GuiPerson> verification;

        public When_randomizer_dont_produce_random_values()
        {
            mapping = new Mapping<DomainPerson, GuiPerson>();
            verification = new MapperVerification<DomainPerson, GuiPerson>(mapping);
            mapping.AutoRelateEqualNames();
        }

        [Fact]
        public void If_same_value_as_reciever_Should_throw_meaningful_exception_because_we_cant_validate_mapping()
        {
            var sameName = "Tore";
            verification.AddRandomizer(typeof(String),()=> sameName);
            Assert.Throws(typeof(GlueException), ()=>verification.AssertMapsCorrectlyTowards(new GuiPerson{FirstName = sameName} ));

        }

        [Fact]
        public void If_different_value_than_reciever_Should_map_anyway()
        {
            verification.AddRandomizer(typeof(String), () => "Henning");
            verification.AssertMapsCorrectlyTowards(new GuiPerson { FirstName = "Tore" });
        }
    }
}